<?php 
	global $post; 
	$redirect_url = esc_attr($_SERVER["REQUEST_URI"]);
	$redirect_url = mb_ereg_replace("&action=[^&]","",$redirect_url);
	
	echo '<p>'.$redirect_url.'</p>';

?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" 
	method="post" class="comment-form">

<p><?php _e('According to our confidentiality policy, your comments will never be published.  They will be answered personally through the given email address.','nucleo'); ?> </p>

<?php 
	if ( is_user_logged_in() ) : 
//		$profileurl = get_option('siteurl').'/wp-admin/profile.php';
//		$profilelink = '<a href="'.$profileurl.'">'.$user_identity.'</a>';
		$userid = '<b>'.$user_identity.'</b>';
?>

<p><?php 
		printf(__('You are logged in as %s.','nucleo'), $userid ); 
		if ( !get_option('comment_registration') ) {
			echo ' ';
			printf(__('Do you want to <a href="%s">log out?</a>','nucleo'), 
						wp_logout_url($redirect_url) ); 
		} 
?></p>

<?php 
	else : 
		$req = get_option('require_name_email',true);
		$commenter = wp_get_current_commenter();
?>

<div id="comment-author" class="text <?php if ($req) echo 'required'; ?>">
	<label for="author"><?php _e('Name','nucleo'); ?></label>
	<input type="text" name="author" id="author" <?php if ($req) echo 'aria-required="true"'; ?> 
		value="<?php echo esc_attr($commenter['comment_author']); ?>" tabindex="1" />
</div>

<div id="comment-author-email" class="text email <?php if ($req) echo 'required'; ?>">
	<label for="email"><?php _e('Email','nucleo'); ?></label>
	<input type="text" name="email" id="email" <?php if ($req) echo 'aria-required="true"'; ?> 
		value="<?php echo esc_attr($commenter['comment_author_email']); ?>" tabindex="2" />
</div>

<!--
<div id="comment-author-url" class="text url">
	<label for="url"><?php _e('Website','nucleo');?></label>
	<input type="text" name="url" id="url" 
		value="<?php echo esc_attr($commenter['comment_author_url']); ?>" tabindex="3" />
</div>
-->

<?php endif; ?>

<div id="comment-text" class="text required">
	<label for="comment"><?php _e('Comment','nucleo'); ?></label>
	<textarea name="comment" id="comment" tabindex="4"></textarea>
</div>

<div id="comment-submit" class="submit">
	<input type="hidden" name="redirect_to" 
		value="<?php echo $redirect_url; ?>&action=submit" />
	<?php comment_id_fields(); ?> 
	<?php do_action('comment_form', $post->ID); ?>
	<input type="submit" name="submit" id="submit" tabindex="5" 
		value="<?php _e('Send your comment','nucleo'); ?>" 
		onclick="return checkSubmit();"/>
	<!-- 
	<input type="button" name="clear" id="clear" tabindex="6" 
		value="<?php _e('Clear fields','nucleo'); ?>"/> 
	-->
	<?php if ( __is_comments_in_popup() ) : ?>
	<input type="button" name="close" id="close" tabindex="7" 
		value="<?php _e('Close this window','nucleo'); ?>" 
		onclick="window.close()" />	
	<?php endif; ?>
	<script language="javascript">
		<!--
		function checkSubmit() {
			i = 0;
			fields = new Array(); 
			$required = $('.required');
			$required.each( function (index) {
				$input = $(this).children('input,textarea');
				$(this).removeClass('error');
				if ( $input.val().trim().length == 0 ) {
					$(this).addClass('error');
					fields[i++] = $(this).children('label').text();
				}
			});
			if ( fields.length > 0 ) {
				if ( fields.length == 1 ) {
					alert( 'Por favor, preencha o campo ' + fields[0] + '.' );
				}
				else {
					flds = fields.join(', ');
					flds = flds.replace(/,[^,]*$/,' e'+flds.match(/[^,]*$/));
					alert( 'Por favor, preencha os campos ' + flds + '.' );
				}
				return false;
			}
			return true;
		}
		$(document).ready( function() {
			srch = location.search;
			srch = srch.replace(/^\?/,'');
			args = srch.split('&');
			for ( i = 0; i < args.length; i++ ) {
				a = args[i].split('=');
				if ( a[0] == 'err' ) {
					alert( decodeURIComponent(a[1]) );
				}
			}
		});
		//-->
	</script>
</div>

</form>